// CPorts.h: interface for the CPorts class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_CPORTS_H__631473E2_F58F_42EF_BB8E_3CBEC4F74A62__INCLUDED_) #define AFX_CPORTS_H__631473E2_F58F_42EF_BB8E_3CBEC4F74A62__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 //File Headers// #include #include "Common.h" #include "CText.h" #include "CTextPage.h" //Communication Errors Messages// typedef BYTE COMMERR; #define COMM_OK 0x00 //Everything is okay #define COMMERR_OUTOFMEM 0x01 //Not enough memory to perform the action. #define COMMERR_OPEN 0x10 //The port is already opened. #define COMMERR_INVALID 0x11 //The port is not available. #define COMMERR_FAILPROP 0x12 //The communication properties failed to work. //Port Definitions// #define PORT_COM 0x00 #define PORT_LPT 0x01 class CPorts { public: //Port Selection & type INT m_nPortNum; BYTE m_byPortType; //Port properties. INT m_nBaudRate; BYTE m_byParity; BYTE m_byByteSize; BYTE m_byStopBits; private: HANDLE m_hPort; DWORD m_dwAbortOnError; INT m_nInBufferSize; INT m_nOutBufferSize; public: CPorts(); virtual ~CPorts(); //Port controls COMMERR OpenPort(BYTE byPortType, INT nPortNum); COMMERR ClearPort(); void ClosePort(); //Misc BOOL TestPort(BYTE byPortType, INT nPortNum); INT FindAvailablePort(); //Write & Read data. BOOL WriteString(CText buffer); BOOL WriteString(char* Buffer); BOOL WriteByte(BYTE byValue); BOOL ReadPort(char* hcBuffer, int* pnSizeRead, int nSizeToRead); private: COMMERR SetupPort(); }; #endif // !defined(AFX_CPORTS_H__631473E2_F58F_42EF_BB8E_3CBEC4F74A62__INCLUDED_)